﻿<?php 
	include_once $_SERVER['DOCUMENT_ROOT'].'/ad/sys/com/model/db/DBConn.php';
?>

{
    "dateTimeFormat": "iso8601",
     "events": [	
<?php 
		$dbConn = new DBConn();
		$sql = "select *  from ad";	
		$topics = mysql_query($sql);
	    $output = "";
	     
		while ($row = @mysql_fetch_object($topics)) {
			
			$title = $row->Title;
			//$datetime = date("r", strtotime("$year-$month-$day $hour:$minutes:00"));
			$date =  $row->AdStartDate ;
			$end = $row->AdEndDate;
			// 廣告狀態 0.審理中 1.刊登中 2.已結束,3 暫停 4.刪除
			$statusText = "";
			$color = '';
			switch($row->Status) {
				case "0" : $statusText = "審理中";  $color ='limegreen'; break;
				case "1" : $statusText = "刊登中";  $color ='bule'; break;
				case "2" : $statusText = "已結束";  $color ='red'; break;
				case "3" : $statusText = "暫停";    $color ='Purple'; break;
				case "4" : $statusText = "刪除";    $color ='slategray'; break;
			};

			
			
			
			$context = '廣告建立者帳號  : '.$row->Account.'<br>'.
					   '宣傳活動名稱  : '.$row->AdName.'<br>'.
					   '廣告狀態 : '. $statusText;
			
			
			
			$context .= $row->Description;
			//$id = $row->id;
			
			$output .= "{'title': '$title',  'color' : '$color','start': '$date', 'end' : '$end', 'description': '$context'  },";
			
			
		} 
		
		if (strlen($output) > 0 ) {
		  echo  substr($output, 0, strlen($output)-1);
		}
	?>
	 ]
}
